using System;
using System.ComponentModel;
using System.Data;
using System.Collections.Generic;

namespace PlacementManager
{
    
    public partial class LinkContactAttributeContactComponent
    {
		//
		// TODO: Add constructor logic here
		//


        /// <summary>
        /// Selects all records from the database table based on a foreign key.
        /// </summary>
        /// <returns>A collection of objects of a type representing a row in the database table.</returns>
        [DataObjectMethodAttribute(DataObjectMethodType.Select, false)]
        public List<LinkContactAttributeContact> SelectAllWContactIdContactAttributeId(int ContactId, int ContactAttributeId, string sortExpression)
        {
            List<LinkContactAttributeContact> listLinkContactAttributeContact = new List<LinkContactAttributeContact>();
            PlacementManager.DAL.LinkContactAttributeContact_DAL o = new PlacementManager.DAL.LinkContactAttributeContact_DAL();
            o.ContactId = ContactId;
            o.ContactAttributeId = ContactAttributeId;
            DataSet ds = o.SelectAllWContactIdContactAttributeId();
            foreach (DataRow row in ds.Tables[0].Rows)
            {
                listLinkContactAttributeContact.Add(new LinkContactAttributeContact((int)row["ContactAttributeContactId"], (int)row["ContactAttributeId"], (int)row["ContactId"], (bool)row["IsActive"], (DateTime)row["DateCreated"], (string)row["CreatedBy"], (DateTime)row["DateUpdated"], (string)row["UpdatedBy"]));
            }
            if (sortExpression == string.Empty)
            {
                sortExpression = "DateCreated desc";
            }
            listLinkContactAttributeContact.Sort(new LinkContactAttributeContactComparer(sortExpression));
            return listLinkContactAttributeContact;
        }
	}
}
